USE [master]
GO

/****** Object:  Database [ELO]    Script Date: 08/27/2008 12:06:23 ******/
CREATE DATABASE [ELO] ON  PRIMARY 
( NAME = N'ELO', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\ELO.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'ELO_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\ELO_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [ELO] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [ELO].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [ELO] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [ELO] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [ELO] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [ELO] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [ELO] SET ARITHABORT OFF 
GO

ALTER DATABASE [ELO] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [ELO] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [ELO] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [ELO] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [ELO] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [ELO] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [ELO] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [ELO] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [ELO] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [ELO] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [ELO] SET  DISABLE_BROKER 
GO

ALTER DATABASE [ELO] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [ELO] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [ELO] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [ELO] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [ELO] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [ELO] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [ELO] SET  READ_WRITE 
GO

ALTER DATABASE [ELO] SET RECOVERY FULL 
GO

ALTER DATABASE [ELO] SET  MULTI_USER 
GO

ALTER DATABASE [ELO] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [ELO] SET DB_CHAINING OFF 
GO

ALTER DATABASE [ELO] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [ELO] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [ELO] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [ELO] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [ELO] SET ARITHABORT OFF 
GO

ALTER DATABASE [ELO] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [ELO] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [ELO] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [ELO] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [ELO] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [ELO] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [ELO] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [ELO] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [ELO] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [ELO] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [ELO] SET  DISABLE_BROKER 
GO

ALTER DATABASE [ELO] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [ELO] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [ELO] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [ELO] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [ELO] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [ELO] SET  READ_WRITE 
GO

ALTER DATABASE [ELO] SET RECOVERY FULL 
GO

ALTER DATABASE [ELO] SET  MULTI_USER 
GO

ALTER DATABASE [ELO] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [ELO] SET DB_CHAINING OFF 
GO

USE [ELO]
GO

/****** Object:  Table [dbo].[Games]    Script Date: 08/27/2008 12:05:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Games](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Date] [date] NOT NULL,
	[Winner] [bigint] NOT NULL,
	[Loser] [bigint] NOT NULL,
	[TotalPoints] [int] NULL,
	[Gammon] [int] NULL,
	[Backgammon] [int] NULL,
	[TotalMoney] [float] NULL,
 CONSTRAINT [PK_Games] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Games] ADD  CONSTRAINT [DF_Games_Points]  DEFAULT ((1)) FOR [TotalPoints]
GO

ALTER TABLE [dbo].[Games] ADD  CONSTRAINT [DF_Games_Gammon]  DEFAULT ((0)) FOR [Gammon]
GO

ALTER TABLE [dbo].[Games] ADD  CONSTRAINT [DF_Games_Backgammon]  DEFAULT ((0)) FOR [Backgammon]
GO

USE [ELO]
GO

/****** Object:  Table [dbo].[Players]    Script Date: 08/27/2008 12:06:06 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Players](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[Wins] [bigint] NOT NULL,
	[Losses] [bigint] NOT NULL,
	[Rating] [bigint] NOT NULL,
 CONSTRAINT [PK_Players] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Players] ADD  CONSTRAINT [DF_Players_Wins]  DEFAULT ((0)) FOR [Wins]
GO

ALTER TABLE [dbo].[Players] ADD  CONSTRAINT [DF_Players_Losses]  DEFAULT ((0)) FOR [Losses]
GO

ALTER TABLE [dbo].[Players] ADD  CONSTRAINT [DF_Players_Rating]  DEFAULT ((1500)) FOR [Rating]
GO

USE [ELO]
GO

/****** Object:  Table [dbo].[Payments]    Script Date: 08/28/2008 15:12:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Payments](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[From] [bigint] NOT NULL,
	[To] [bigint] NOT NULL,
	[Amount] [float] NOT NULL,
	[TransactionDate] [date] NOT NULL,
 CONSTRAINT [PK_Payments] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

